#ifndef __THREAD_POOL__
#define __THREAD_POOL__
#include "numStack.h"
#include <mysql/mysql.h>
#include <my_header.h>
#include <openssl/sha.h>
#include <my_header.h>
#include "tidArr.h"
#include "taskQueue.h"
#define PRE_PATH "/home/cheese/study/test2/cloud-storage-project/wp-v3/userfile"
typedef struct train_s{
    int flag;//新增加的
    int length;
    char data[1000];
}train_t;

//线程池基础
typedef struct threadPool_s
{
    tidArr_t tidArr; //线程id数组
    taskQueue_t taskQueue;//任务队列
    pthread_mutex_t mutex;
    pthread_cond_t cond;
    int exitFlag;
}threadPool_t;

int threadPoolInit(threadPool_t *pthreadPool,int workerNum);
int makeWorker(threadPool_t *pthreadPool);
int initTcp(char *ip, char *port);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);


int randomSaltValue(char *salt);//随机生成盐值

int func_pwd(char * ant,numStack_t * stack,MYSQL * mysql);
int func_cd(char * path,numStack_t * stack,MYSQL * mysql,char * user_name);
int func_ls(char * ant,numStack_t * stack,MYSQL * mysql);
int func_puts(int netfd,char * file_name,numStack_t * stack,MYSQL * mysql,char * user_name);
int func_remove(char *fileName,MYSQL *mysql,numStack_t * stack);
int func_mkdir(char *user_name,numStack_t *stack,char *fileName,MYSQL *mysql);
int func_rmdir(numStack_t *stack,char *dirName,MYSQL *mysql);
int recvn(int sockfd,void *buf,int length);
char *file_sha1(char *filename);
//gets
//int quik_send(char *hash,MYSQL *mysql);
int quick_send(char *hash,MYSQL *mysql);
int recv_file(numStack_t *stack,char *hash,char *userName,int netfd,MYSQL *mysql);
int check_file_full(numStack_t *stack,char *hash,char *fileName,MYSQL *mysql);

//numStack.c
/*
int numStackInit(numStack_t * pstack);
int pushStack(numStack_t * pstack,int num);
int popStack(numStack_t * pstack);
int visitStack(numStack_t * pstack);
int topStack(numStack_t * Pstack);
int empty(numStack_t * Pstack);
*/
#endif
